<template>
	<view>
		<view class="zh">账号登录</view>
		<view class="box">
			<view class="xian">
				<view class="inp">
					<text>+86</text>
					<image src="../../static/login_bottom.png" mode=""></image>
					<input type="digit" v-model="mobile" placeholder="请输入您的手机号码" placeholder-style="font-size: 36rpx; color: #BFBFBF;" style="padding-left: 30rpx;" />
				</view>
				<view style="height: 2rpx; width: 100%; background: #E9E9E9;"></view>
			</view>
			<view class="xian" style="margin-top: 40rpx;">
				<view class="inp">
					<input type="password" @keydown.enter="login" v-model="password" placeholder="请输入您的密码" placeholder-style="font-size: 36rpx; color: #BFBFBF;" />
					<!-- <text class="yzm">发送验证码</text> -->
				</view>
				<view style="height: 2rpx; width: 100%; background: #E9E9E9;"></view>
			</view>
		</view>
		<view style="display: flex;justify-content: space-between;padding: 16rpx 50rpx; font-size: 30rpx;">
			<view @click="zhuce">新用户注册</view>
			<view @click="backIndex" style="color: #3291F8;">前往首页</view>
		</view>
		<view class="dl">
			<view class="dll" @click="login">
				登录
			</view>
			<!-- <view class="dll" >
				注册
			</view>
			<view class="dll" >
				回到首页
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mobile:'',
				password:''
			}
		},
		// 隐藏左上角返回按钮
		// mounted() {
		// 	var a = document.getElementsByClassName('uni-page-head-hd')[0]
		// 	a.style.display = 'none';
		// },
		methods: {
			zhuce(){
				uni.navigateTo({
					url:'./register'
				})
			},
			backIndex(){
				uni.switchTab({
					url:'../index/index'
				})
			},
			async login(){
				if(this.mobile==''||this.password==''){
					return uni.showToast({
						title: '您还有未填写资料请检查',
						duration: 1500,
						icon:'none'
					});
					
				}
				const res = await this.post('/Index/index/login',{mobile:this.mobile,password:this.password})
				if(res.code==200){
					console.log("-=--")
					// uni.setStorageSync('auth',res.data.token);
					uni.setStorage({
					    key: 'auth',
					    data: res.data.token,
					    success: function () {
							
					    }
					});
					uni.showToast({
						title:'登录成功',
						duration: 1000,
						icon:'none',
						success() {
							setTimeout(() => {
								uni.reLaunch({
									url:'../index/index',
								});
							},1000);
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.dl{
		padding: 0 40rpx;
		.dll{
			width: 100%;
			height: 90rpx;
			color: #FFFFFF;
			margin: 10rpx 0;
			font-size: 36rpx;
			line-height: 90rpx;
			text-align: center;
			border-radius: 15rpx;
			background-color: #3291F8;
		}
	}
	.zh{
		font-size: 64rpx;
		margin: 90rpx 0 90rpx 40rpx;
	}
	.box{
		.xian{
			padding: 0 44rpx;
			.inp{
				display: flex;
				align-items: center;
				margin-bottom: 30rpx;
				box-sizing: border-box;
				text{
					color: #404040;
					font-size: 32rpx;
					margin-right: 10rpx;
				}
				image{
					width: 28rpx;
					height: 28rpx;
				}
				input{
					width: 100%;
					line-height: 100rpx;
				}
				.yzm{
					width: 300rpx;
					color: #3291F8;
				}
			}
		}
	}
</style>
